# sethome
Minetest sethome mod for beds (teleport for beds).
Teleporting player to bed if he slept on it after writing in chat /home.
Tested on default beds from minetest_game.

http://forum.minetest.net/viewtopic.php?f=9&t=13788

If you want use PilzAdam's beds mod you must replace all code in init.lua by this:

minetest.register_on_chat_message(function(name, message, playername, player)

	local player_spawns = {}
	
	local file = io.open(minetest.get_worldpath().."/beds_player_spawns", "r")
	
	if file then
	
		player_spawns = minetest.deserialize(file:read("*all"))
		
		file:close()
		
	end
	
	local cmd = "/home"
	
	local player = minetest.get_player_by_name(name)

	
	    if message:sub(0, #cmd) == cmd then
	    
	        if message == '/home' then
	        
			if (player_spawns[name]) then
			
		        minetest.chat_send_player(player:get_player_name(), "Teleporting to bed...")
		        
		        player:setpos(player_spawns[name])
		        
		        return true 
		        
else 

		minetest.chat_send_player(player:get_player_name(), "You haven't slept in a bed yet.")
		
		return true
		
	        end
	        
	    end
	    
	
	end
	
end)


minetest.register_chatcommand("sethome", {

	--params = "",
	
	description = "Information about set your home point",
	
	func = function(name)
	
		local player = minetest.get_player_by_name(name)
		
		if player == nil then
		
                -- just a check to prevent the server crashing
                
                return false
                
                end
                
		minetest.chat_send_player(player:get_player_name(), "You must sleep in a bed for this.")
		
		return true
		
	end,
	
}) 

